package selenium.test;

import org.junit.Test;
import org.scub.foundation.framework.client.test.SeleniumTestCase;


/**
 * This is a simple test which will create a new contact and verify if the contact is visible in the list of contacts.
 * @author Clément Lavaud (clement.lavaud@scub.net)
 */
public class ExampleIT extends SeleniumTestCase {

    @Test
    public void testExample() throws Exception {
                
        selenium.setSpeed("1500"); // the speed between each instruction in the test (in milliseconds)
        selenium.open("http://localhost:8080/contact-manager-spring-mvc-client/login.jsp");
        selenium.type("name=j_username", "user");
        selenium.type("name=j_password", "user");
        selenium.click("name=submit");
        
         
        selenium.open("http://localhost:8080/contact-manager-spring-mvc-client/index.jsp");
     
        selenium.click("link=Moteur de recherche");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=commonSearchFieldId", "nad");
        selenium.click("css=button.btn");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("Nicolas"));
        assertFalse(selenium.isTextPresent("Raphael"));
        selenium.type("id=commonSearchFieldId", "go");
        selenium.click("css=button.btn");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("Juanito"));
        assertTrue(selenium.isTextPresent("Stéphane"));
         
        selenium.click("link=Nouveau contact");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=radioCivilite1");
        selenium.type("id=inputPrenom", "prenomSelenium");
        selenium.type("id=inputNom", "nomSelenium");
        selenium.click("css=button.btn");
        selenium.type("name=emails[0]", "prenomSelenium@scub.net");
        selenium.click("css=button.btn");
        selenium.type("name=emails[1]", "nomSelenium@scub.net");
        selenium.click("css=#parentListTel > button.btn");
        selenium.type("name=telephones[0]", "0555454545");
        selenium.click("css=#submitRow > button.btn");
        selenium.waitForPageToLoad("30000");
        
        selenium.click("link=Moteur de recherche");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("prenomSelenium"));
        assertTrue(selenium.isTextPresent("nomSelenium"));
        
           }

}
